#include "race_tree_model_node.h"

RaceTreeModelNode::RaceTreeModelNode(RaceItem* race)
  : Race(race)
{
}

RaceTreeModelNode::RaceTreeModelNode(const wxString& nodeName)
  : Race(0)
  , ContainerName(nodeName)
{
}

RaceTreeModelNode::~RaceTreeModelNode()
{
  for (size_t i = 0; i < Children.size(); ++i)
  {
    RaceTreeModelNode *child = Children[i];
    delete child;
  }
}

bool RaceTreeModelNode::IsContainer() const
{
  return (Race == 0);
}

RaceTreeModelNode* RaceTreeModelNode::GetParent()
{
  return Parent;
}

RaceTreeModelNodePtrArray& RaceTreeModelNode::GetChildren()
{
  return Children;
}

RaceTreeModelNode* RaceTreeModelNode::GetChild(size_t n)
{
  return Children[n];
}

void RaceTreeModelNode::Insert(RaceTreeModelNode* child, size_t n)
{
  Children.insert(Children.begin() + n, child);
}

void RaceTreeModelNode::Append(RaceTreeModelNode* child)
{
  Children.push_back(child);
}

unsigned int RaceTreeModelNode::GetChildCount() const
{
  return Children.size();
}

